<%@ page language="java" import="java.util.*,com.sjw.model.*"
	pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>YouAndMe</title>
<meta name="description" content="YouAndMe" />
<meta name="keywords" content="YouAndMe" />
<meta name="viewport"
	content="width=1000, initial-scale=1.0, maximum-scale=1.0">

<!-- Loading Bootstrap -->
<link href="dist/css/vendor/bootstrap.min.css" rel="stylesheet">

<!-- Loading Flat UI -->
<link href="dist/css/flat-ui.css" rel="stylesheet">
<link href="docs/assets/css/demo.css" rel="stylesheet">

<link rel="shortcut icon" href="img/pig.jpg">
<script src="dist/js/vendor/jquery.min.js"></script>

<!-- HTML5 shim, for IE6-8 support of HTML5 elements. All other JS at the end of file. -->
<!--[if lt IE 9]>
      <script src="dist/js/vendor/html5shiv.js"></script>
      <script src="dist/js/vendor/respond.min.js"></script>
    <![endif]-->
<script type="text/javascript">
	javascript: window.history.forward(1);
</script>
<script type="text/javascript">
	function Showregister(s) {
		if (s=='login') {
			document.getElementById('form_login').style.display = "";
			document.getElementById('form_registe').style.display = "none";
		} else {
			document.getElementById('form_login').style.display = "none";
			document.getElementById('form_registe').style.display = "";
			$("#registerusername").val("");//清空input

		}
	}

	function checkusername() {
		// 		alert($("#registerusername").length);//测试是否存在该ID的input
		var username = $("#registerusername").val();//取框中的id用户名
		username = $.trim(username);
		// 				alert(username);
		if (username != "") {
			var url = "user_checkUserName";
			var args = {
				"username" : username
			};
			$.post(url, args, function(data) {
				//0是不存在,1是存在
				if (data == "0") {
					alert("恭喜,该用户名可用");
				} else if (data == "1") {
					alert("抱歉,用户名    " + username + "    已存在");
					$("#registerusername").val("");//清空input
					$("#registerusername").focus();//获得焦点
				} else {
					alert("未知错误,正在努力检修");
				}
			});
		} else {
			alert("用户名不可为空");
			$("#registerusername").val("");//清空input
			$("#registerusername").focus();//获得焦点
		}
	}
</script>
</head>
<body style="background-image: url(img/bgimg.png);">
	<div class="container">
		<div class="login">
			<div class="login-screen">
				<div class="login-icon">
					<img src="img/gotokaifeng.jpg" alt="Welcome to YouAndMe" />
					<h4>
						Welcome to <small>YouAndMe</small>
					</h4>
				</div>
				<!--登录 -->
				<form method="post" action="user_login" id="form_login">
					<div class="login-form">
						<div class="form-group">
							<input name="user.username" type="text"
								class="form-control login-field" value=""
								placeholder="Enter your name" id="loginusername"
								required="required" /> <label class="login-field-icon fui-user"
								for="user.username"></label>
						</div>

						<div class="form-group">
							<input name="user.password" type="password"
								class="form-control login-field" value="" placeholder="Password"
								id="user.password" required="required" /> <label
								class="login-field-icon fui-lock" for="user.password"></label>
						</div>

						<input class="btn btn-primary btn-lg btn-block" type="submit"
							value="Login" /> <input class="btn btn-primary btn-lg btn-block"
							type="reset" value="JoinUs" onclick="Showregister('register')" />
					</div>
				</form>
				<!--           注册 -->
				<form id="form_registe" method="post" action="user_registe"
					style="display: none">
					<div class="login-form">
						<div class="form-group">
							<input name="user.username" type="text"
								class="form-control login-field" value=""
								placeholder="Enter your name" id="registerusername"
								required="required" onchange="checkusername();" /> <label
								class="login-field-icon fui-user" for="user.username"></label>
						</div>

						<div class="form-group">
							<input name="user.password" type="password"
								class="form-control login-field" value="" placeholder="Password"
								id="user.password" required="required" /> <label
								class="login-field-icon fui-lock" for="user.password"></label>
						</div>

						<div class="form-group">
							<input name="repassword" type="password"
								class="form-control login-field" value=""
								placeholder="rePassword" id="repassword" required="required" />
							<label class="login-field-icon fui-lock" for="repassword"></label>
						</div>
						<input class="btn btn-primary btn-block" type="submit"
							value="JoinUs" /> <input class="btn btn-primary btn-block" type="reset"
							onclick="Showregister('login')" value="GoBack" />
					</div>
				</form>
			</div>
		</div>
	</div>
	<script src="dist/js/vendor/video.js"></script>
	<script src="dist/js/flat-ui.min.js"></script>
	<script src="docs/assets/js/application.js"></script>
</body>
</html>
